<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/add.css"/>
</head>
<body>
<div id="app">
    <div class="header">
        <span>添加快递员</span>
    </div>
    <div class="content">
        <table>
            <tr>
                <td class="text-right">姓名</td>
                <td class="content_right"><input class="input" placeholder="请输入姓名"></td>
            </tr>
            <tr>
                <td class="text-right" >手机号码</td>
                <td class="content_right"><input class="input" placeholder="请输入手机号码" id="check_phone"></td>
            </tr>
            <tr>
                <td class="text-right">身份证号码</td>
                <td class="content_right"><input class="input" placeholder="请输入身份证号码"id="check_idcard"></td>
            </tr>
            <tr>
                <td class="text-right">密码</td>
                <td class="content_right"><input class="input" placeholder="请输入密码"></td>
            </tr>
            <tr>
                <td></td>
                <td class="content_right"><span class="btn btn-info" id="check" id="insest">立即提交</span> <span class="btn">重置</span></td>
            </tr>
        </table>


    </div>
</div>
<script src="../../assets/layui.all.js"></script>
<script src ="/qrcode/jquery2.1.4.js"></script>
<script src="/layer/layer.js"></script>

<script>
    var form = layui.form, layer = layui.layer;
</script>
<script>
    //校验手机号
    $("#check_phone").mouseenter(function () {
        $("#check_phone").css({"background": "rgba(234,97,97,0)"})
    });
    $("#check_idcard").mouseenter(function () {
        $("#check_idcard").css({"background": "rgba(234,97,97,0)"})
    });


    $("#check").click(function () {

        var Phone = $("input:eq(1)").val();
        if (Phone.match(/^[0-9_]{11}$/) == null) {

            layer.msg("输入错误，请输入正确的手机号");
            $("#check_phone").css({"background": "rgba(234,97,97,0.3)"});
            return false;
        }
        var IDCard = $("input:eq(2)").val();
        if (IDCard.match(/^[0-9A-Za-z_]{18}$/) == null) {

            layer.msg("输入错误，请输入正确的身份证号");
            $("#check_idcard").css({"background": "rgba(234,97,97,0.3)"});
            return false;
        }

        return true;
    });
</script>
<script>

    $(function () {
        $("#insest").click(function () {
            var windowId = layer.load();
            var c_name = $("input:eq(0)").val();
            var c_phone = $("input:eq(1)").val();
            var c_idcard = $("input:eq(2)").val();
            var c_password = $("input:eq(3)").val();
            $.post("/courier/insert.do",{
                c_name:c_name,
                c_phone:c_phone,
                c_idcard:c_idcard,
                c_password:c_password

            },function (data){
                layer.close(windowId);
                layer.msg(data.result);
                if (data.status == 0){
                    $("input").val("");
                }


            });
            return false;

        });
    });
</script>
</body>
</html>
